//存
export const setItem = (key,value) =>{
    //如果是对象就把value转成字符串,否则就不需要再转了
    if(typeof value==='value'){
        value=JSON.stringify(value)
    }
    localStorage.setItem(key,value)
}
//读
export const getItem=key =>{
    const data = localStorage.getItem(key)
    try {
        return JSON.parse(data)
    } catch (error) {
        return data
    }
}
//删